package com.rd.student.jiaji.class3.sunguowei.kaoshi;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.Scanner;

public class First {
    public static void main(String[] args) throws IOException {
        File file=new File("Student.txt");
        Writer writer = new FileWriter(file);
        writer.write("姓名 语文成绩 数学成绩 总分"+"\n");
        for (int i = 0; i < 3; i++) {
            Scanner scanner=new Scanner(System.in);
            System.out.println("输入姓名：");
            String name=scanner.next();
            System.out.println("输入语文成绩：");
            int chineseScore=scanner.nextInt();
            System.out.println("输入数学成绩：");
            int mathScore=scanner.nextInt();
            int total=chineseScore+mathScore;
            Student student=new Student(name,chineseScore,mathScore,total);
            writer.write(String.valueOf(student));

        }
        writer.close();

    }

    static class Student{
         String name;
         int chineseScore;
         int mathScore;
         int total;

         public Student(String name,int chineseScore,int mathScore,int total){
             this.name=name;
             this.chineseScore=chineseScore;
             this.mathScore=mathScore;
             this.total=total;
         }

        @Override
        public String toString() {
            return name +" "+chineseScore+" "+mathScore+" "+total+"\n";
        }
    }
}
